package com.hqyj.javaSpringBoot.modules.common.entity;

import org.apache.commons.lang3.StringUtils;

public class SearchBean {
    public final static int DEFAULT_CURRENT_PAGE=1;
    public final static int DEFAULT_PAGE_SIZE=5;
    private int currentPage;
    private int pageSize;
    private String orderBy;
    private String direction;
    private String keyWord;

    public void initSearchBean(){
        if (this==null){
//            this.currentPage=DEFAULT_CURRENT_PAGE;
//            this.pageSize=DEFAULT_PAGE_SIZE;
            return;
        }
            this.currentPage=this.currentPage==0?DEFAULT_CURRENT_PAGE:this.currentPage;
            this.pageSize=this.pageSize==0?DEFAULT_PAGE_SIZE:this.getPageSize();


//        if (StringUtils.isBlank(this.orderBy)){
//            this.orderBy="id";
//        }
//        if (StringUtils.isBlank(this.direction)){
//            this.orderBy="asc";
//        }
//        if (StringUtils.isBlank(this.keyWord)){
//            this.orderBy="";
//        }

    }
    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }
}
